package com.qf.day13.mail;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashSet;

public class MailDemo {

    public static void main(String[] args) {

        MailInfo m1 = new MailInfo("阿里云", "abc", new Date(), "djl");
        MailInfo m2 = new MailInfo("Gitee", "仓库变更", new Date(System.currentTimeMillis()-1000000), "aaa");
        MailInfo m3 = new MailInfo("steam", "账号被登录了", new Date(), "djl");
        MailInfo m4 = new MailInfo("Gitee", "仓库变更", new Date(), "djl");

        ArrayList<MailInfo> mailInfos = new ArrayList<>();
        mailInfos.add(m1);
        mailInfos.add(m2);
        mailInfos.add(m3);
        mailInfos.add(m4);

        System.out.println(mailInfos);

        //1. 把邮件进行去重显示，同时保留邮件的接收顺
        //2. 重复的判断依据为 ，邮件的发件人和邮件的标题都一直，就算重复邮件

        LinkedHashSet<MailInfo> set = new LinkedHashSet<>(mailInfos);
        System.out.println(set);


    }

}
